package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class Borrowed implements Ioperation {
    @Override
    public void work(BookList booklist) {
        System.out.println("输入你要借阅的书籍");
        Scanner scan = new Scanner(System.in);
        String bookName = scan.nextLine();

        for (int i = 0; i < booklist.getCurrentSize(); i++) {
            Book book = booklist.getBooks(i);
            if(book.getName().equals(bookName)){
                if(book.isBorrowed() == true){
                    System.out.println("该书已被借出，无法借阅.....");
                }else {
                    System.out.println("你成功借阅了这本书......");
                    book.setBorrowed(true);
                }
                return;
            }
        }
        System.out.println("没有这本书......");
    }
}
